import os
import sys
from .buildin.asserter import Assert
from .kernel.logger.AutoLogging import Log
from .kernel.runner.BaseTest import BaseTestCase
from .kernel.runner import TestStepper as stepper
from .kernel.runner import test
from .kernel.modle.Decorator import singleton
from .kernel.modle.Decorator import log_decorator
from .kernel.modle.HookImpl import HookImpl
from .kernel.modle.Variable import Var


def get_config():  # 获取配置文件信息
    return Var.Config


def get_task_id():  # 获取任务编号
    return Var.Project.TaskId


def get_report_path():  # 获取报告路径
    return Var.Project.ReportPath


def get_root_path():  # 获取工程路径
    return Var.Project.RootPath


def get_testcase_id():  # 获取用例编号
    return Var.Case.CaseID


def get_testcase_result():  # 获取用例执行结果
    return Var.Case.CaseResult


def get_testcase_log_path():  # 获取用例级别log存放路径
    return os.path.join(Var.Project.ReportPath, "log", Var.Case.CaseID)


def main(testcase=None):
    from autotest.kernel.runner.TestProject import TestProject
    prj_path = sys.argv[0].split("testcase")[0] if "testcase" in sys.argv[0] else os.path.split(sys.argv[0])[0]
    sys.path.insert(0, os.path.join(prj_path, "testcase"))
    prj = TestProject(os.path.join(prj_path, "config.yaml"), testcase=testcase)
    prj.setup()
    prj.run()
    prj.teardown()


